<template>
  <div class="mod-menu">

    <div class="mt30">
      <el-form :inline="true" :model="params" style="text-align: center;">
        <el-form-item label="核销码">
          <el-input style="width:400px" v-model="params.verification" placeholder="请输入订单核销码" clearable></el-input>
        </el-form-item>

        <el-form-item>
          <el-button @click="loadList()">查询</el-button>
          <el-button v-if="btnshow" type="primary" @click="addOrUpdateHandle()">核销</el-button>
        </el-form-item>
      </el-form>
    </div>

    <div class="table-data" v-loading="tableLoading">
      <div class="table-content" v-for="(v,i) in dataList" :key="i">
        <div class="goods-info">
          <div class="good-img-div">
            <img :src="v.goods_img" />
          </div>
          <div class="info">
            <div class="goods-title">{{v.goods_title}}</div>
            <div class="price">￥
              <span class="can-inpu">{{v.real_price}}</span>
            </div>
            <div class="remark">x{{v.number}}</div>
            <div class="remark">{{v.sku_set_name}}</div>
          </div>
        </div>

      </div>

    </div>
    <div v-if="dataList.length==0" class="no-data">
      暂无数据
    </div>

  </div>
</template>

<script>
import orderService from '@/api/orderService.js'

export default {
  data () {
    return {
      params: {
        verification: null

      },
      tableLoading: false,
      btnshow: false,
      dataList: []

    }
  },
  components: {

  },
  created () {

  },
  methods: {

    loadList () {
      if (this.params.verification) {
        this.tableLoading = true
        orderService.verficationApi(this.params).then(res => {
          if (res.data && res.data.code == 200) {
            this.tableLoading = false
            this.dataList = res.data.data.child_order_list
            this.btnshow = true
          } else {
            this.tableLoading = false
          }
        }).then(res => {
          this.tableLoading = false
        })
      } else {
        this.$message.warning('请输入核销码')
      }
    },

    addOrUpdateHandle () {
      if (this.params.verification) {
        orderService.verification(this.params).then(res => {
          if (res.data && res.data.code == 200) {
            this.$message.success('核销成功！')
          } else {
          }
        })
      } else {
        this.$message.warning('请输入核销码')
      }
    },

    /**
     * 核销
     * */
    verificationMethod (item) {
      this.verification = true
      this.$nextTick(() => {
        this.$refs.verification.init(item)
      })
    },

    /**
     * 没有发货直接退款
     * */

    refund (id) {
      console.log(id)
      this.$confirm('确认是否退款？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        orderService.orderRefund(id).then(res => {
          if (res.data && res.data.code == 200) {
            this.$message.success('退款成功！')
            this.loadList()
          }
        })
      }).catch(() => {
      })
    }
  }
}
</script>
<style scoped lang="scss">
.mt30 {
  margin-top: 30px;
}

.good-img-div {
  img {
    width: 85px;
    height: 85px;
    display: flex;
  }
}

.flex_bet {
  display: flex;
  justify-content: space-between;
}

.title-div {
  padding: 0 30px;
  height: 40px;
  background-color: #e5e5e5;
  color: #333333;
  line-height: 40px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
}

.tc {
  text-align: center;
}

.table-data {
  .alipay {
    color: #009fe8;
  }

  .wechatpay {
    color: #1aad19;
  }

  .platformpay {
    color: #17b3a3;
  }

  > div {
    border: 1px solid #f0f0f0;
  }

  .table-content {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;

    > div {
      min-width: 15%;
    }

    .goods-info {
      display: flex;
      align-items: center;
      width: 100%;

      .info {
        text-align: left;
        margin-left: 10px;
        width: 60%;
      }

      .goods-title {
        font-size: 14px;
        height: 30px;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
      }

      .remark {
        font-size: 12px;
        color: #b1b1b1;
      }

      .price {
        font-size: 14px;
        color: #f3415f;
        margin-bottom: 15px;
        display: flex;
        align-items: center;

        i {
          cursor: pointer;
        }
      }

      .price > input {
        border: none;
        color: #f3415f;
        width: auto;
        width: 50%;
        padding: 5px;
        margin: 0 2px;
        box-sizing: border-box;
        // transition: all .3s;
      }

      input:focus {
        outline: unset;
      }
    }
  }

  .table-foot {
    height: 40px;
    text-align: right;
    color: #333333;
    line-height: 40px;
    font-size: 14px;
    padding: 0 15px;

    .price {
      color: #f3415f;
    }

    .freight {
      color: #b1b1b1;
      margin-right: 10px;
    }
  }
}

.ml10 {
  margin-left: 10px;
}

.can-input {
  border: 1px solid #dfdfdf !important;
  border-radius: 2px;
}
.cosstype {
  text-align: center;
  div {
    margin-bottom: 10px;
  }
}
</style>
